package com.un10.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.un10.entity.Administrator;
import com.un10.entity.User;
import com.un10.service.UserService;
import com.un10.util.Result;

@Controller
public class UserContorller {

	@Autowired
	UserService UserService;

	@RequestMapping("/houtai/getAllUser")
	@ResponseBody
	public Object getPropicinfo(@RequestParam("page") int page, @RequestParam("limit") int limit,
			@RequestParam("userName") String userName, @RequestParam("thecode") String thecode) {

		List<User> user = UserService.findAllUser((page - 1) * limit, limit, userName, thecode);

		if (userName == null || userName == "") {
			userName = null;
		}
		if (thecode == null || thecode == "") {
			thecode = null;
		}
		int count = UserService.getCount();
		System.out.println(userName);
		com.un10.util.Result res = new com.un10.util.Result(0, "", count, user);
		return res;
	}

	@RequestMapping("/houtai/useradd")
	@ResponseBody
	public Object useradd(@RequestParam Map<String, Object> map) {

		System.out.println(map.get("userName"));
		int i = UserService.findUserAdd(map);
		Result res = new Result(0, "", i, true);
		return res;
	}

	@RequestMapping("/houtai/UserUpdate")
	@ResponseBody
	public Object updateUser(@RequestParam Map<String, Object> map) {

		int i = UserService.findUserUpdate(map);
		Result res = new Result(0, "", i, true);
		return res;
	}

	@RequestMapping("/houtai/userdelete")
	@ResponseBody
	public Object userdelete(@RequestParam("userID") Integer userID) {
		int i = UserService.findUserDelete(userID);
		Result res = new Result(0, "", i, true);
		return res;
	}

	/**
	 * //前台登录
	 * 
	 */

	
	 
}